<!--<a href="#/layui/busiguanli" class="layui-btn layui-btn-xs layui-btn-primary" style="margin: 20px 0 0 100px;">
  <i class="layui-icon">&#xe65c;</i>
</a>-->

<form action="" class="layui-form">
	<div class="layui-fluid">
		<div class="layui-card">
			<!--<div class="layui-container">-->
				<div class="layui-row">
			    <div class="layui-col-md12">
			    	
			      <h2 class="title">
			      	<a href="#/layui/busiguanli" class="layui-btn layui-btn-xs layui-btn-primary" style="margin: -0px 0 0 0;border: none;background-color: rgba(0,0,0,0);">
							  <i class="layui-icon">&#xe65c;</i>
							</a>
			      	编辑商圈</h2>
			      
			      
			      	<div class="layui-card-body">
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">商圈名称：<span class="haveTo">*</span></div>
			      			<div class="layui-input-block">
			      				<input type="text" name="busiName" lay-verify="required" class="layui-input busiName">
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">商圈等级：</div>
			      			<div class="layui-input-block">
			      				<select name="memLev" class="memLev">
								        </select>
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">商圈区域：<span class="haveTo">*</span></div>
			      			<div class="layui-input-block clearfix">
			      				<div class="select200 fl">
					      				<select name="province" class="province" lay-verify="required" lay-filter="province">
												  <option value="">省份</option>
												</select> 
					      			</div>
					      			<div class="select200 fl">
					      				<select name="city" class="city" lay-filter="city">
													  <option value="">城市</option>
													</select> 
					      			</div>
					      			<div class="select200 fl">
					      				<select name="area" class="Area" lay-filter="Areas">
															  <option value="">区域</option>
															</select> 
					      			</div>
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">商圈所属分会：</div>
			      			<div class="layui-input-block">
			      				<select name="fenduo" lay-verify="" class="fenduo">
													  <option value="">请选择</option>
													</select>
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">简介：</div>
			      			<div class="layui-input-block">
			      				<textarea name="picTitle" class="picTitle layui-textarea" rows="" cols=""></textarea>
			      				<!--<input type="text" name="picTitle" class="layui-input picTitle" placeholder="图片标题" >-->
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">商圈LOGO：</div>
			      			<div class="layui-input-block">
			      				<table class="layui-table fenhuiPic" lay-skin="nob">
					      				<tr>
					      					<td><!--分会照片显示-->
					      						<label for="fhPicSub" class="addLogo">
					      							<img src="img/addImg.png" class="fhImg" />
					      						</label>
					      					</td>
					      					<td></td>
					      				</tr>
					      				<tr>
					      					<td>
					      						
					      						<!--<label for="fhPicSub" class="layui-btn addLogo">
														  <i class="layui-icon">&#xe67c;</i>添加/修改LOGO
														</label>-->
														<input type="file" id="fhPicSub" onchange="uploadPhoto2(this)" style="display: none;" />
														<table class="layui-table" lay-skin="nob">
					      							<tr>
					      								<td><button class="layui-btn layui-btn-danger delPic" type="button">删除</button></td>
					      								<td></td>
					      							</tr>
					      						</table>
					      					</td>
					      					<td>
					      						
					      					</td>
					      				</tr>
					      				
					      			</table>
			      			</div>
			      		</div>
			      		
			      		
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">商圈照片：</div>
			      			<div class="layui-input-block">
			      				<table class="layui-table" lay-size="lg" lay-skin="nob">
				      				<tbody>
				      					<tr>
				      						<td class="prodDe_td" lay-filter="xiangqing">
				      						</td>
				      						<!--<td>
												<button class="layui-btn layui-btn-danger cover_delPic">删除</button>
				      						</td>-->
				      					</tr>
				      					<tr>
				      						<td>
				      							<input type="file" class="detail_input" style="display: none;" onchange="uploadPhoto3(this)">   
				      						
				      							<button type="button" class="layui-btn" id="test1" onclick="coverDetail()">
															  <i class="layui-icon">&#xe67c;</i>添加图片
															</button>
														<button class="layui-btn layui-btn-danger delDeImg" type="button">删除</button> 
				      						</td>
				      					</tr>
				      				</tbody>
				      			</table>
			      			</div>
			      		</div>
			      		
			      		<div class="layui-form-item">
			      			<div class="layui-form-label"></div>
			      			<div class="layui-input-block">
			      				<button class="layui-btn confirm" lay-submit type="button" lay-filter="queding">确定</button>
			      			</div>
			      		</div>
			      		
			      	</div>
			      	
			      	
			      	<!--<table class="layui-table" lay-size="lg" lay-skin="nob">
					      
					      <tbody>
					      	
					      	<tr>
					      		<td class="small_td">商圈名称：</td>
					      		<td><input type="text" name="busiName" lay-verify="required" class="layui-input busiName input33"></td>
					      	</tr>
					      	<tr>
					      		<td class="small_td">商圈等级：</td>
					      		<td>
					      			<div class="select25">
						      			<select name="memLev" class="memLev">
								        </select>
							        </div>
					      		</td>
					      	</tr>
					      	<tr>
					      		<td class="small_td">商圈区域：</td>
					      		<td class="clearfix">
					      			<div class="select200 fl">
					      				<select name="province" class="province" lay-verify="" lay-filter="province">
												  <option value="">省份</option>
												</select> 
					      			</div>
					      			<div class="select200 fl">
					      				<select name="city" class="city" lay-verify="" lay-filter="city">
													  <option value="">城市</option>
													</select> 
					      			</div>
					      			<div class="select200 fl">
					      				<select name="area" class="Area" lay-verify="" lay-filter="Areas">
															  <option value="">区域</option>
															</select> 
					      			</div>
					      		</td>
					      	</tr>
					      	<tr>
					      		<td class="small_td">商圈所属分会：</td>
					      		<td>
					      			<div class="select25">
						      			<select name="fenduo" lay-verify="" class="fenduo">
													  <option value="">请选择</option>
													</select> 
											</div>
					      		</td>
					      	</tr>
					      	<tr>
					      		<td class="small_td">商圈LOGO：</td>
					      		<td>
					      			<table class="layui-table" lay-skin="nob">
					      				<tr>
					      					<td>
					      			<table class="layui-table fenhuiPic" lay-skin="nob">
					      				<tr>
					      					<td>
					      						<label for="fhPicSub" class="addLogo">
					      							<img src="img/addImg.png" class="fhImg" />
					      						</label>
					      					</td>
					      					<td></td>
					      				</tr>
					      				<tr>
					      					<td>
														<input type="file" id="fhPicSub" onchange="uploadPhoto2(this)" style="display: none;" />
														<table class="layui-table" lay-skin="nob">
					      							<tr>
					      								<td><input type="text" name="picTitle" class="layui-input picTitle" placeholder="图片标题" ></td>
					      								<td><button class="layui-btn layui-btn-danger delPic" type="button">删除</button></td>
					      							</tr>
					      						</table>
					      					</td>
					      					<td>
					      						
					      					</td>
					      				</tr>
					      				
					      			</table>
					      		</td>
					      				</tr>
					      			</table>
					      		</td>
					      	</tr>
					      	<tr>
					      		<td class="small_td">分会照片：</td>
					      		<td>
					      			<table class="layui-table" lay-size="lg" lay-skin="nob">
				      				<tbody>
				      					<tr>
				      						<td class="prodDe_td" lay-filter="xiangqing">
				      						</td>
				      					</tr>
				      					<tr>
				      						<td>
				      							<input type="file" class="detail_input" style="display: none;" onchange="uploadPhoto3(this)">   
				      						
				      							<button type="button" class="layui-btn" id="test1" onclick="coverDetail()">
															  <i class="layui-icon">&#xe67c;</i>添加图片
															</button>
														<button class="layui-btn layui-btn-danger delDeImg" type="button">删除</button> 
				      						</td>
				      					</tr>
				      				</tbody>
				      			</table>
					      		</td>
					      	</tr>
					      	
						    
						  </tbody>
					      	
				      </table>
			    </div>
			    
			    <div class="layui-col-md10">
			    	<div class="addFHBtn">
						<button class="layui-btn confirm" lay-submit type="button" lay-filter="queding">确定</button>
					</div>
			    </div>-->
			    
			  </div>
			</div>


		</div>
	</div>
</form>


<script type="text/javascript">
	let delDeImg = document.querySelector(".delDeImg")
	let downArr = [];
	let delArr = [];
	let busiName = document.querySelector(".busiName");
	let busiStar = document.querySelector(".busiStar");
	let busiArea = document.querySelector(".busiArea");
	let prodDe_td = document.querySelector(".prodDe_td");
	let addr = document.querySelector(".addr");
	let fenduo = document.querySelector(".fenduo");
	let addPic = document.querySelector(".addPic");
	let picTitle = document.querySelector(".picTitle");
	let delPic = document.querySelector(".delPic");
	let confirm = document.querySelector(".confirm");
	let province = document.querySelector(".province");
	let city = document.querySelector(".city");
	let Area = document.querySelector(".Area");
	let fhImg = document.querySelector(".fhImg");
	let memLev = document.querySelector(".memLev");
	let ciArr = [];
	let photo = '';
	let cityCode = '';
	let AreaCode = "";
	let areaCode = '';
	let areas = '';
	let photos = [];
	let sheng='';
	let shi='';
	let qu='';
	
//	上传图片方法

function coverDetail(){
		$('.detail_input').click()
	}

	function uploadPhoto2(file) {
		    console.log(file.files[0])
		
		    var data = new FormData();
		    data.append("file", file.files[0]);
		    
		
		    $.ajax({
		      url:DBHelper.host+'/api/ImgUpload?MemLoginId=admit&ImagesType=',
		      type: 'POST',
		      dataType: 'JSON',
		      data: data,
		      beforeSend: function(request) {
		           
		            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
		        },
		      cache: false,
		      processData: false,
		      contentType: false,
					success:function(res){
						let fhImg = document.querySelector(".fhImg");
						console.log(res.Url)
						fhImg.setAttribute("src",res.Url)
						photo = res.Url;
						$('.loading').remove()
					},
					error:function(res){
						$('.loading').remove()
					}
		    })
		  }
	
//	多图添加
//	删除按钮,修改delDeImg和prodDe_check
	delDeImg.addEventListener("click",function(){
		let de_td = document.querySelectorAll(".prodDe_td");
		let des = document.querySelectorAll(".prodDe_check");
		let ts = document.querySelectorAll(".prodDe_checkbox");
		let a = 0;
		let del = [];
		console.log(ts)
		ts.forEach((el,index)=>{
			console.log(el.checked)
			
			if(el.checked){
				del.push(index)
				
//					photos.splice(index-a,1)
				delArr = [...delArr,...photos.splice(index-a,1)]
				a++;
				el.parentNode.parentNode.removeChild(el.parentNode)
			}
		})
		console.log("del",delArr)
		
			console.log("photos",photos)
	})
//	每一个多图上传的方法都不一样,回调函数内容不一样
	function uploadPhoto3(file) {
    console.log(file.files[0])

    var data = new FormData();
    data.append("file", file.files[0]);
    

    $.ajax({
      url:DBHelper.host+'/api/ImgUpload?MemLoginId=admit&ImagesType=',
      type: 'POST',
      dataType: 'JSON',
      data: data,
      beforeSend: function(request) {
		            
		            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
		        },
      cache: false,
      processData: false,
      contentType: false,
			success:function(res){
				
//				let fhImg = document.querySelector(".fhImg");
//				console.log(res.Url)
//				fhImg.setAttribute("src",res.Url)
//				photo = res.Url;
//				prodBg.setAttribute("src",res.Url)
//				prodDe_td.innerHTML += `
//				<div class="prodDe_check">
//					<img src="${res.Url}" style="width: 100px;height: 100px;margin-bottom:20px;" />
//					<input type="text" class="layui-input prodDe_input" placeholder="名字"  />
//					<input type="checkbox" name="prodDe_check" class="prodDe_checkbox" lay-skin="primary" value="${res.Url}">
//				</div>
//				
//				`
				$(".prodDe_td").append('<div class="prodDe_check"><img src="'+res.Url+'" style="width: 100px;height: 100px;margin-bottom:20px;" /><input type="text" class="layui-input prodDe_input" placeholder="名字"  /><input type="checkbox" name="prodDe_check" class="prodDe_checkbox" lay-skin="primary" value="'+res.Url+'"></div>');
				renderForm();
				
//				let prodDe_input = document.querySelector(".prodDe_input");
//				console.log(prodDe_input);
				let imgObj = {
					Guid:"00000000-0000-0000-0000-000000000000",
					Images:res.Url
				};
				
				photos.push(imgObj);
				$('.loading').remove()
//					console.log(res)
//				console.log("photos",photos)
			},
			error:function(res){
				$('.loading').remove()
			}
    })
  }
	
	
//	删除LOGO	
		delPic.addEventListener("click",function(){
			fhImg.setAttribute("src","");
			photo = '';
			
		})
	
	
	
layui.use(['jquery', 'mockjs', 'table', 'sidebar', 'form','route'], function () {
		var $ = layui.jquery,
      layer = layui.layer,
      table = layui.table,
      sidebar = layui.sidebar,
      route = layui.route,
      params = route.params(),
      form = layui.form;
  		
  		renderForm();
  		
  		let _obj = {
  			"Guid": "00000000-0000-0000-0000-000000000000",
			  "MemLoginId": "",
			  "Name": busiName.value,
			  "Photo": "",
			  "Brief": "",
			  "Area": "",
			  "AreaCode": "",
			  "RankGuid": "",
			  "CategoryId": 2,
			  "MemberCount": "0",
			  "InCircleGuid": "",
			  "CreateUser": "",
			  "CreateTime": "",
			  "IsAudit": 1,
			  "AuditTime": "",
			  "RankScore": 1,
			  "ModifyUser": "",
			  "ModifyTime": ""
  		}
  		
//		商圈所属分会
			
		DBHelper.PostA("Filtrate_Xn_Circle",{
			CategoryId: 1,
			CurrentPage: 1,
			PageSize: 10,
			RankGuid: ""
		},function(data){
			console.log("分会",data._Data)
			data._Data.forEach((el,index)=>{
		    		  	let op = document.createElement('option');
		    		  	op.value = el.Guid;
		    		  	op.innerText = el.Name;
		    		  	fenduo.appendChild(op)
		    		  	
		    		  })
			renderForm();
			
		},function(data){
			console.log(data)
		})
  		
  		
				function _confirm (){
						sheng = $(".province option:selected").text();
						shi = $(".city option:selected").text();
						qu = $(".Area option:selected").text();
      			if($(".province option:selected").text()=="省份"){
      				sheng = ''
      			}
      			if($(".city option:selected").text()=="城市"){
      				shi=''
      			}
      			if($(".Area option:selected").text()=="区域"){
      				qu=''
      			}
						areas = sheng+shi+qu;
						_obj.Name = busiName.value;
//						_obj.Photo = addPic.value;
//						_obj.Brief = picTitle.value;
//						_obj.Area = busiArea.value;
						_obj.Photo = photo;
						_obj.Brief = picTitle.value;
						_obj.InCircleGuid = $("select[name='fenduo'] option:selected").val();
						_obj.AreaCode = areaCode;
						_obj.Area = areas;
//						_obj.IsAudit = 1;
						_obj.RankGuid = $("select[name='memLev'] option:selected").val()
//						_obj.RankGuid = busiStar.value;
						
//						获取每个分会的输入框
						let titles = document.querySelectorAll(".prodDe_input")
							console.log("titles",titles)
							console.log("photos",photos)
							titles.forEach((el,index)=>{
//								debugger
								console.log(el.value)
								console.log("index",index)
								photos[index].Name = el.value;
							})
						
						
						if(params == null) {
							_obj.CreateUser = localStorage.getItem("user")
							_obj.CreateTime = getNowFormatDate();
							 
//							_obj.CreateTime = new Date();
							DBHelper.Post("Admin_Xn_Circle", _obj, function(data) {
								console.log(data)
								
//								上传分会图片
								photos.forEach((el,index)=>{
									el.CircleGuid = data.Guid;
									console.log("imgEl",el)
									DBHelper.Post("Admin_Xn_CircleImages",el,function(data){
//										debugger
										console.log(data,"成功")
									},function(data){
										console.log(data)
									})
								})
								let index = layer.alert("操作成功",function(){
										window.location.href="#/layui/busiguanli"
										layer.close(index)
								})
								
							}, function(data) {
								console.log(data)
							});
						} else {
							_obj.ModifyUser = localStorage.getItem("user")
							_obj.ModifyTime = getNowFormatDate();
							_obj.Guid = params.id;
							_obj.Name = busiName.value;
							console.log("_obj",_obj);
							
//								上传分会图片
								
								console.log("photos",photos)
								photos.forEach((el,index)=>{
//									el.CircleGuid = data.Guid;
									if(el.Guid=="00000000-0000-0000-0000-000000000000"){
										el.CircleGuid = params.id;
										DBHelper.Post("Admin_Xn_CircleImages",el,function(data){
//											debugger
											console.log(data,"成功")
										},function(data){
											console.log(data)
										})
									}else{
										console.log("imgEl",el)
										DBHelper.Put("Admin_Xn_CircleImages?id="+el.Guid,el,function(data){
	//										debugger
											console.log(data,"成功")
											delArr.forEach((el,index)=>{
												DBHelper.Delete("Admin_Xn_CircleImages?id="+el.Guid,function(data){
													console.log(data,"删除成功")
												},function(data){
													console.log(data)
												})
											})
											
										},function(data){
											console.log(data)
										})
									}
									
								})
							
//							_obj.ModifyTime = new Date();
							DBHelper.Put("Admin_Xn_Circle?id=" + params.id, _obj, function(data) {
								console.log("data",data)
								let index = layer.alert("操作成功",function(){
										window.location.href="#/layui/busiguanli"
										layer.close(index)
								})
							}, function(data) {
								console.log(data)
							})
						}
					}
				
				DBHelper.GetA("GetXn_RankByCategoryId?id=2",function(data){
          	console.log(data)
          	data.forEach((el,index)=>{
		    		  	let op = document.createElement('option');
		    		  	op.value = el.Guid;
		    		  	op.innerText = el.Name;
		    		  	memLev.appendChild(op)
		    		  	
		    		  })
          	form.render();
          },function(data){
          	console.log(data)
          })
      
      
      if(params){
      	
//    	获取图片
      	DBHelper.Get("Admin_Xn_CircleImages",function(data){
//								console.log(data,"123")
								data.forEach((el,index)=>{
									if(el.CircleGuid==params.id){
										photos.push(el);
										downArr.push(el);
									}
								})
								console.log("photos",photos)
//								多图下载到本地
								photos.forEach((el,index)=>{
			      			prodDe_td.innerHTML += `
									<div class="prodDe_check">
										<img src="${el.Images}" style="width: 100px;height: 100px;margin-bottom:20px;" />
										<input type="text" class="layui-input prodDe_input" placeholder="名字" value="${el.Name}"  />
										<input type="checkbox" name="prodDe_check" class="prodDe_checkbox" lay-skin="primary" value="${el.Images}">
									</div>
									
									`
									
									renderForm();
	      		})
							},function(data){
								debugger
								console.log(data)
							})
      	
      	
      	DBHelper.Get("Admin_Xn_Circle?id="+params.id,function(data){
      		photo = data.Photo;
      		busiName.value=data.Name;
//    		busiStar.value=data.InCircleGuid;
      		fhImg.setAttribute("src",photo);
      		picTitle.value = data.Brief;
      		$(".memLev").find("option[value='"+data.RankGuid+"']").prop("selected",true);
      		_obj = data;
      		console.log(1,data)
      		
//    		_obj = {
//		  			"Guid": "00000000-0000-0000-0000-000000000000",
//					  "MemLoginId": "",
//					  "Name": busiName.value,
//					  "Photo": "",
//					  "Brief": "",
//					  "Area": "",
//					  "AreaCode": "",
//					  "RankGuid": "",
//					  "CategoryId": 2,
//					  "MemberCount": data.MemberCount,
//					  "InCircleGuid": "",
//					  "CreateUser": data.CreateUser,
//					  "CreateTime": data.CreateTime,
//					  "IsAudit": 1, 
//					  "AuditTime": "",
//					  "RankScore": 1,
//					  "ModifyUser": "",
//					  "ModifyTime": ""
//		  		}
      		
      		
      		console.log("thisdata",data)
      		
      		let proCode = data.AreaCode.substr(0,3);
      		let cityCode = data.AreaCode.substr(0,6);
      		console.log("proCode",proCode);
      		console.log("cityCode",cityCode);
      		defultArea(proCode,cityCode,data.AreaCode,'https://xnsmb.xnsoft.net.cn/api/GetXn_DispatchRegion');
      		areaCode = data.AreaCode;
      		
      		$(".fenduo").find("option[value='"+data.InCircleGuid+"']").prop("selected",true);
//    		$("select[name='fenduo'] option:selected").val()
      	},function(data){
      		console.log(data)
      	})
      }
      
//    confirm.addEventListener("click",_confirm)
      
      //    省市区三级
			takeArea();

      function takeArea(){
      	let proArr = [];
      	
      	$.ajax({//异步请求返回给后台
		    	  url:'https://xnsmb.xnsoft.net.cn/api/GetXn_DispatchRegion',
		    	  type:'get',
		    	  beforeSend: function(request) {
		            
		            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
		        },
		    	  data:{FatherId:'0'},
		    	  dataType:'json',
		    	  success:function(data){
		    		  //这里获取到数据执行显示
		    		  proArr = [...data]
//		    		  console.log("地址data",data)
							let p = document.createElement('option');
							p.value='';
							p.innerText="省份";
		    		  data.forEach((el,index)=>{
		    		  	let op = document.createElement('option');
		    		  	op.value = el.ID;
		    		  	op.innerText = el.Name;
		    		  	province.appendChild(op)
		    		  	
		    		  })
		    		  renderForm();
		    	  }
		    	  
		      });
		      
		      form.on('select(province)', function(data){
						cityCode = data;
						console.log(1,data)
						proArr.forEach((el,index)=>{
		      				if(el.ID==data.value){
		      					areaCode=el.Code;
		      				}
		      			})
						if(data.value==""){
		      				areaCode="";
		      			}
		      			console.log("areaCode",areaCode);
			//			console.log("seFrist",seFrist)
//					  console.log(data.value);
					  $.ajax({//异步请求返回给后台
					    	  url:'https://xnsmb.xnsoft.net.cn/api/GetXn_DispatchRegion',
					    	  type:'get',
					    	  data:{FatherId:data.value},
					    	  dataType:'json',
					    	  beforeSend: function(request) {
					            
					            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
					        },
					    	  
					    	  success:function(data){
					    	  	ciArr = [...data];
					    		  //这里获取到数据执行显示
					    		  console.log(data)
			//		    		  console.log("secJobs",secJobs.length)
			//							secJobs="";
										$(".city").empty();
										let p = document.createElement('option');
										p.value = "";
										p.innerText = "城市";
										city.appendChild(p)
					    		  data.forEach((el,index)=>{
					    		  	let op = document.createElement('option');
					    		  	op.value = el.ID;
					    		  	op.innerText = el.Name;
			//		    		  	op.id = el.Id;
					    		  	city.appendChild(op)
					    		  })
					    		  renderForm();
					    		  
					    	  }
					    	  
					      });
					});   
					
					form.on('select(city)', function(data){
						let _city = data.value;
						AreaCode = data;
						if(data.value==""){
	      				areaCode=areaCode.substr(0,3);
	      			}
			//			console.log("seFrist",seFrist)
//					  console.log(data.value);
					  $.ajax({//异步请求返回给后台
					    	  url:'https://xnsmb.xnsoft.net.cn/api/GetXn_DispatchRegion',
					    	  type:'get',
					    	  data:{FatherId:data.value},
					    	  dataType:'json',
					    	  beforeSend: function(request) {
		            
		            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
		        },
					    	  
					    	  success:function(data){
					    	  	ciArr.forEach((el,index)=>{
					    		  	if(el.ID==_city){
					    		  		areaCode=el.Code
					    		  	}
					    		  })
					    	  	 console.log("areaCode",areaCode)
					    		  //这里获取到数据执行显示
//					    		  console.log(data)
			//		    		  console.log("secJobs",secJobs.length)
			//							secJobs="";
										$(".Area").empty();
										let p = document.createElement('option');
										p.value = "";
										p.innerText = "区域";
										Area.appendChild(p)
					    		  data.forEach((el,index)=>{
					    		  	let op = document.createElement('option');
					    		  	op.value = el.Code;
					    		  	op.innerText = el.Name;
			//		    		  	op.id = el.Id;
					    		  	Area.appendChild(op)
					    		  })
					    		  renderForm();
					    		  
					    	  }
					    	  
					      });
					}); 
					
					form.on('submit(queding)',_confirm)
					
					form.on('select(Areas)', function(data){
						if(data.value!=""){
							areaCode = $(".Area option:selected").val();
//							areas = $(".province option:selected").text()+$(".city option:selected").text()+$(".Area option:selected").text();
						}else{
							areaCode=areaCode.substr(0,6);
						}
//						areas = $(".province option:selected").text()+$(".city option:selected").text()+$(".Area option:selected").text();
						console.log(areaCode);
						console.log(areas)
					})
					
      }
      
      function renderForm(){
		  layui.use('form', function(){
		   var form = layui.form;//高版本建议把括号去掉，有的低版本，需要加()
		   form.render();
		  });
		}
  		
  		
  		
//		显示默认的地址
  		
      function defultArea(proCode,cityCode,AreaCode,baseUrl){
      	$.ajax({//异步请求返回给后台
		    	  url:baseUrl,
		    	  type:'get',
		    	  data:{FatherId:'0'},
		    	  dataType:'json',
		    	  beforeSend: function(request) {
		            
		            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
		        },
		    	  success:function(data){
		    		  //这里获取到数据执行显示
//		    		  console.log("地址data",data)
							let p = document.createElement('option');
							let proValue="";
							p.value='';
							p.innerText="省份";
		    		  data.forEach((el,index)=>{
		    		  	let op = document.createElement('option');
		    		  	if(el.Code==proCode){
		    		  		proValue=el.ID;
		    		  	}
		    		  	
		    		  	op.value = el.ID;
		    		  	op.innerText = el.Name;
		    		  	province.appendChild(op)
//		    		  	console.log(op.id)
		    		  })
		    		  $(".province").find("option[value='"+proValue+"']").prop("selected",true);
		    		  
		    		  $.ajax({//异步请求返回给后台
				    	  url:baseUrl,
				    	  type:'get',
				    	  data:{FatherId:proValue},
				    	  dataType:'json',
				    	  beforeSend: function(request) {
		            
		            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
		        },
				    	  success:function(data){
				    		  //这里获取到数据执行显示
//				    		  console.log("地址data",data)
									let p = document.createElement('option');
									ciArr = [...data];
									let cityValue="";
									p.value='';
									p.innerText="城市";
				    		  data.forEach(function(el,index){
				    		  	let op = document.createElement('option');
				    		  	if(el.Code==cityCode){
				    		  		cityValue=el.ID;
//				    		  		console.log(el.)
				    		  	}
				    		  	
				    		  	op.value = el.ID;
				    		  	op.innerText = el.Name;
				    		  	city.appendChild(op) 
//				    		  	console.log(op.id)
				    		  })
				    		  $(".city").find("option[value='"+cityValue+"']").prop("selected",true);
				    		  renderForm();
				    		  
				    		  $.ajax({//异步请求返回给后台
							    	  url:baseUrl,
							    	  type:'get',
							    	  data:{FatherId:cityValue},
							    	  dataType:'json',
							    	  beforeSend: function(request) {
		            
		            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
		        },
							    	  success:function(data){
							    		  //这里获取到数据执行显示
//							    		  console.log("地址data",data)
												let p = document.createElement('option');
												let areaValue="";
												p.value='';
												p.innerText="城市";
							    		  data.forEach(function(el,index){
							    		  	let op = document.createElement('option');
							    		  	if(el.Code==AreaCode){
//							    		  		areaValue=el.ID;
//							    		  		console.log("el.areaValue",areaValue)
															
							    		  	}
							    		  	
							    		  	op.value = el.Code;
							    		  	op.innerText = el.Name;
							    		  	Area.appendChild(op); 
			//				    		  	console.log(op.id)
							    		  })
							    		  $(".Area").find("option[value='"+AreaCode+"']").prop("selected",true);
							    		  renderForm();
							    		  
							    		  
							    		  
							    	  }
							    	  
							      });
				    		  renderForm();
				    	  }
				    	  
				      });
		    		  
		    		  
		    		  renderForm();
		    	  }
		    	  
		      });
		      
      }
      
})

	function renderForm(){
		  layui.use('form', function(){
		   var form = layui.form;//高版本建议把括号去掉，有的低版本，需要加()
		   form.render();
		  });
		}
	
	
</script>




	<style scoped>
				.small_td{
					width: 100px;
					text-align: right;
				}
				.haveTo{
					color: red;
				}
				.fhImg{
					width: 100px;
					height: 100px;
					/*background-image: url(img/addImg.png);*/
				}
				.prodDe_check{
      		/*padding-top: 5px;*/
					width: 100px;
					padding: 12px;
					text-align: center;
					display: inline-block;
					/*border: 1px solid black;*/
				}
      	.title{
      		/*margin-left: 30px;*/
      		margin-top: 30px;
      	}
      	.checkBtn{
      		border-radius: 5px;
      		width: 100px;
      	}
      	.listBtns{
      		display: flex;
      		justify-content: space-between;
      		width: 100%;
      	}
      	.listBtn{
      		border-radius: 5px;
      	}
      	.addFHBtn{
      		text-align: center;
      		margin-top: 20px;
      		margin-bottom: 20px;
      	}
      	.addFHBtn button{
      		display: inline-block;
      		width: 300px;
      	}
      </style>
       
      